package com.xiaolin.oa.controller;

import com.github.pagehelper.PageInfo;
import com.xiaolin.oa.annotations.HasApi;
import com.xiaolin.oa.model.dto.BuOvertimeDto;
import com.xiaolin.oa.model.dto.OvertimeQuery;
import com.xiaolin.oa.model.entity.BuOvertime;
import com.xiaolin.oa.service.BuOvertimeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author xiaolin
 * @description 描述
 * @since 2024/7/12
 */
@Api("加班资源")
@RestController
@RequestMapping("/overtime")
public class BuOvertimeController {

    @Autowired
    private BuOvertimeService overtimeService;

    @HasApi({"overtime:home"})
    @ApiOperation("获取加班列表")
    @PostMapping("/getPage/{page}/{pageSize}")
    public PageInfo<BuOvertimeDto> getOvertimePage(@PathVariable Integer page,
                                                   @PathVariable Integer pageSize,
                                                   @RequestBody OvertimeQuery query) {
        return overtimeService.getOvertimePage(page, pageSize, query);
    }

    @HasApi({"overtime:add"})
    @ApiOperation("添加加班")
    @PostMapping("/add")
    public boolean addOvertime(@RequestBody BuOvertime overtime) {
        return overtimeService.addOvertime(overtime);
    }

    @HasApi({"overtime:get"})
    @ApiOperation("获取加班")
    @PostMapping("/get/{id}")
    public BuOvertime getOvertime(@PathVariable("id") Integer id) {
        return overtimeService.getOvertime(id);
    }

    @HasApi({"overtime:update"})
    @ApiOperation("修改加班")
    @PostMapping("/update")
    public boolean updateOvertime(@RequestBody BuOvertime overtime) {
        return overtimeService.updateOvertime(overtime);
    }

    @HasApi({"overtime:del"})
    @ApiOperation("删除加班")
    @PostMapping("/delete/{id}")
    public boolean deleteOvertime(@PathVariable Integer id) {
        return overtimeService.deleteOvertime(id);
    }
}
